package com.sto.stoapp.http.request.upload;

import com.sto.stoapp.db.StoFilePreference;
import com.sto.stoapp.http.request.BaseRequest;
import com.sto.stoapp.util.DateUtil;
import com.sto.stoapp.util.Helper;
import com.sto.stoapp.util.TraceUtil;

import android.content.Context;
import android.os.SystemClock;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;

public class BarInfoRequest extends BaseRequest {

	public BarInfoRequest(Context c) {
		sessionId = StoFilePreference.getInstance(c).getSessionId();
		tid = StoFilePreference.getInstance(c).getMachineCode();
		trace = TraceUtil.getTraceTimes();
		cnt = "1";
		mty = "0854";
		BarInfo info = new BarInfo();
		opRecord = new ArrayList<BarInfo>();

		info.collectTime = DateUtil.getDateTime();
		info.deviceType = "PDA";
		info.memoryTotel = Helper.getTotalMemory(c) + "";

		info.memoryUsable = Helper.getAvailMemory(c) + "";
		info.memoryUsage = (Helper.getTotalMemory(c) - Helper.getAvailMemory(c))
				+ "";
		info.onlineStatus = "1";
		info.opOrgCode = StoFilePreference.getInstance(c).getSiteCode();
		info.opTerminal = StoFilePreference.getInstance(c).getMachineCode();
		info.power = StoFilePreference.getInstance(c).getBatteryLevel();
		info.powerStatus = StoFilePreference.getInstance(c).getBatteryState();

		Calendar now = Calendar.getInstance();
		now.setTimeZone(TimeZone.getTimeZone("Asia/Beijing"));
		now.setTimeInMillis(SystemClock.elapsedRealtime());
		info.useTime = now.get(Calendar.HOUR_OF_DAY) + "hr"
				+ now.get(Calendar.MINUTE) + "min";
		opRecord.add(info);
	}

	public String cnt;
	public List<BarInfo> opRecord;
}
